package com.mzl.lal4cloud.lxw4rf.service.contract.common;

import com.mzl.lal4cloud.lxw4rf.service.contract.bean.HostConfig;
import com.mzl.lal4cloud.lxw4rf.service.contract.config.ConfigStorage;
import lombok.AllArgsConstructor;
import lombok.Getter;

import static com.mzl.lal4cloud.lxw4rf.service.contract.bean.HostConfig.buildUrl;

/**
 * 上上签
 *
 * @author J_luo
 */
public interface ApiUrl {

    /**
     * 得到api完整地址.
     *
     * @param config 获取配置信息
     * @return
     */
    default String getUrl(ConfigStorage config) {
        HostConfig hostConfig = null;
        if (config != null) {
            hostConfig = config.getHostConfig();
        }
        return buildUrl(hostConfig, this.getPath(), this.getDescribe());
    }

    /**
     * the path
     *
     * @return path
     */
    String getPath();

    /**
     * the describe
     * @return
     */
    String getDescribe();


    @Getter
    @AllArgsConstructor
    enum Auth implements ApiUrl {

        GET_TOKEN("/api/oa2/client-credentials/token", "获取Token")

        ;
        private final String path;

        private final String describe;
    }

    /**
     * 合同相关枚举
     */
    @AllArgsConstructor
    @Getter
    enum Contract implements ApiUrl {

        /**
         * 创建并发送合同
         */
        CONTRACT_CREATE("/api/contracts", "创建并发送合同"),

        /**
         * 签署合同
         */
        CONTRACT_SIGN("/api/contracts/sign","签署合同"),

        /**
         * 发送已审批合同
         */
        CONTRACT_SEND_APPROVED("/api/contracts/sendApprovedContract","发送已审批合同"),

        /**
         * 查询合同是否可被代理签署
         */
        CONTRACT_CLECK_PROXY("/api/contracts/check-proxy-sign","查询合同是否可被代理签署"),

        /**
         * 合同代理签署
         */
        CONTRACT_PROXY_SIGN("/api/contracts/proxy-sign","合同代理签署"),

        /**
         * 创建合同草稿
         */
        CONTRACT_DRAFT("/api/contracts/draft","创建合同草稿"),

        /**
         * 查询合同列表
         */
        CONTRACT_CENTER_SEARCH("/api/contract-center/search","查询合同列表"),

       /**
         * 下载合同
         */
        CONTRACT_DOWNLOAD_FILE("/api/contracts/download-file","下载合同"),

        /**
         * 单合同下载
         */
        CONTRACT_DOWNLOAD_ORDER("/api/contracts/downloadByOrder", "单合同下载"),

        /**
         * 下载签约存证页
         */
        CONTRACT_APPENDIX_FILE("/api/contracts/%s/appendix-file?account=%s&enterpriseName=%s","下载签约存证页")

        ;
        private final String path;

        private final String describe;
    }


    /**
     * 模板相关枚举
     */
    @AllArgsConstructor
    @Getter
    enum Template implements ApiUrl {

        /**
         * 模板详情查询
         */
        TEMPLATE_SEARCH("/api/templates/%s", "模板详情查询"),

        /**
         * 查询模版列表
         */
        TEMPLATE_LIST("/api/templates","查询模版列表"),

        /**
         * 发送模板合同
         */
        TEMPLATE_SEND_SYNC("/api/templates/send-contracts-sync", "发送模板合同"),

        /**
         * 添加文档后发送模板合同
         */
        TEMPLATE_ADD_ATT("/api/templates/addAttachmentsToTemplate", "添加文档后发送模板合同"),
        ;
        private final String path;

        private final String describe;
    }

    /**
     * 标签相关枚举
     */
    @AllArgsConstructor
    @Getter
    enum Tags implements ApiUrl {

        /**
         * 模板详情查询
         */
        TAGS_SEARCH("/api/contract-center/business-tags/list-sender-enterprise-tags", "模板详情查询"),


        ;
        private final String path;

        private final String describe;
    }
}
